package ru.cod.rs.main.units;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.SurfaceView;

public abstract class AbstractUnit implements Unit {
	protected int x, y;
	protected int width, height;
	protected SurfaceView view;

	// ////////////////////////////////////////
	public AbstractUnit(SurfaceView v, int abc, int ord) {
		x = abc;
		y = ord;
		view = v;
	}

	public AbstractUnit() {

	}

	public AbstractUnit(SurfaceView v) {
		view = v;
		x = 0;
		y = 0;
	}

	// ////////////////////////////////////////

	/*
	 * @see ru.cod.rs.units.Unit#update()
	 */
	@Override
	public void update() {

	}

	/*
	 * @see ru.cod.rs.units.Unit#render(android.graphics.Canvas)
	 */
	@Override
	public void render(Canvas canvas) {
		Paint paint = new Paint();
		paint.setColor(Color.RED);
		canvas.drawPoint(x, y, paint);
	}

	// ////////////////////////////////////////
	protected Bitmap getBitmap(int id) {
		Resources resources = view.getContext().getResources();
		return BitmapFactory.decodeResource(resources, id);
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * @return the width
	 */
	public int getWidth() {
		return 1;
	}

	/**
	 * @return the height
	 */
	public int getHeight() {
		return 1;
	}

	public abstract void setCoords(int x, int y);

}
